from v3.ResultProcessor import ResultProcessor
import json


class SinaCommentResultProcessor(ResultProcessor):
    def process(self, page):
        download_result = page.get_download_result()
        data = json.loads(download_result)
        data = list(data['data'].values())[0]
        res = []

        for d in data:
            info = {}
            info['id'] = d['user']['id']
            info['time'] = d['created_at']
            info['username'] = d['user']['screen_name']
            info['text'] = d['text']
            res.append((info['id'], info['username'], info['time'], info['text']))
        page.set_result(res)


class SinaUserFansResultProcessor(ResultProcessor):
    def process(self, page):
        print(page.get_download_result())
        pass
